#include "Udpserver.hpp"
#include "Dict.hpp"
#include <memory>
#include <string>

using namespace wxd;
int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        std::cerr << "usage: " << argv[0] << " ip" << std::endl;
        exit(1);
    }

    // std::string ip = argv[1];
    u_int16_t port = std::stoi(argv[1]);

    // 创建字典对象
    Dict dict;
    dict.Load();
    // 将词典的方法传给server
    std::unique_ptr<UdpServer> ptr_server = std::make_unique<UdpServer>(port,[&dict](const std::string& message){
        return dict.Translate(message);
    });

    ptr_server->Init();
    ptr_server->Start();

    return 0;
}
